#include <bits/stdc++.h>
using namespace std;

int a[15][200005], t, n;

int ecsh (int hq, int lq, int w)
{
    if (w == n)
    {
        if (a[t][w] == hq) return hq;
        return 0;
    }
    if (a[t][w] == hq) return hq + max(ecsh(hq, lq, w + 1), ecsh(lq, hq, w + 1));
    hq = a[t][w];
    return max(ecsh(hq, lq, w + 1), ecsh(lq, hq, w + 1));
}

int main()
{
    freopen ("color.in", "r", stdin);
    freopen ("color.out", "w", stdout);
    scanf ("%d", &t);
    while (t--)
    {
        scanf ("%d", &n);
        for (int i = 1; i <= n; i++)
        {
            scanf ("%d", &a[t][i]);
        }
        int ans = max(ecsh(a[t][1], 0, 2), ecsh(0, a[t][1], 2));
        printf ("%d", ans);
    }
    return 0;
}
